// mircoApp/video_sharer/index.js
const app = getApp();
const skinBehavior = require('../../utils/themeSkin/skinBehavior');
import Toast from "../../dist/toast/toast";
Page({

  /**
   * 页面的初始数据
   */
  data: {
    flag:true,
    value: '',
    top_image:"",
    share_desc:"",
    code:"",
    is_share_member:0,
  },

  behaviors: [skinBehavior],
  /**
   * 生命周期函数--监听页面加载
   */
  code_handle(){

  },
  onLoad() {
    this.getData();
  },
  getData() {
    app._getNetWork({
      url: app.getNetAddresss("plugin.video-shop.frontend.share-member.index"),
      success: resdata => {
        let { data, msg, result } = resdata.data;
        if (result !== 1) {
          return app.tips(msg);
        }
        this.setData({
          top_image: data.top_image,
          share_desc: data.share_desc,
          is_share_member:data.is_share_member
        })
      }
    })
  },
  onChange(event) {
    this.setData({value:event.detail.value})
  },
  handle() {
    app._postNetWork({
      url:app.getNetAddresss("plugin.video-shop.frontend.share-member.shareCode"),
      data:{username: this.data.value },
      success:resdata=>{
        let { data, msg, result } = resdata.data;
        if (result !== 1) {
          return Toast(msg)
          // return app.tips(msg);
        }
        this.setData({
          flag:false,
          code: data.code
        })
      }
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})